package com.mstore.dao;

import java.util.List;

import com.mstore.pojo.Reply;
import com.mstore.pojo.WxReplyItem;
/**
 * 多图文
 *
 */
public class WxReplyItemDao extends SuperDao {

	/**
	 * 
	 *保存多图文
	 */
	public void save(WxReplyItem wxReplyItem) {
		super.save(wxReplyItem);
	}

	/**
	 * 
	 * 查询多图文
	 */
	public List<Object> watchReplyItem(Reply reply) {
		String hql = "from Reply where eaId = ? and type = 3";
		Object[] values = new Object[] { reply.getEaId() };
		return super.getObject(hql, values);
	}

	/**
	 * 删除多图文
	 */
	public void delReplyItem(Reply reply) {
		/*String sql = "delete from wx_reply_item where reply_id = "
				+ reply.getId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb=new StringBuilder();
		sb.append("delete from wx_reply_item where reply_id =");
		sb.append(reply.getId());
		super.executeUpdate(sb.toString());
	}

	/**
	 * 
	 * 通过reply_id来查询
	 */
	public List<Object> selectReplyId(Reply reply) {
		String hql = "from WxReplyItem where replyId = ?";
		Object[] values = new Object[] { reply.getId() };
		return super.getObject(hql, values);
	}

	/**
	 * 
	 *  通过Id查找更改
	 */
	public void updateWxReplyItem(WxReplyItem wReplyItem) {
		/*String sql = "update wx_reply_item  set  title= '"
				+ wReplyItem.getTitle() + "', description= '"
				+ wReplyItem.getDescription() + "',  picurl='"
				+ wReplyItem.getPicurl() + "', url= '" + wReplyItem.getUrl()
				+ "'  where id= " + wReplyItem.getId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb=new StringBuilder();
		sb.append("update wx_reply_item  set  title= '");
		sb.append(wReplyItem.getTitle());
		sb.append("', description= '");
		sb.append(wReplyItem.getDescription());
		sb.append("',  picurl='");
		sb.append(wReplyItem.getPicurl());
		sb.append("', url= '");
		sb.append(wReplyItem.getUrl());
		sb.append("'  where id= ");
		sb.append(wReplyItem.getId());
		super.executeUpdate(sb.toString());
	}

	/**
	 * 删除单个图文 
	 */
	public void deleteReplyItem(WxReplyItem wxRepkyItem) {
		/*String sql = "delete from wx_reply_item where id = "
				+ wxRepkyItem.getId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb=new StringBuilder();
		sb.append("delete from wx_reply_item where id = ");
		sb.append(wxRepkyItem.getId());
		super.executeUpdate(sb.toString());
	}
}
